<?php
include("sessionUser.php");
    include("Conexao.php");
    $conexao = new Conexao();
   
    $con = $conexao->conectBD();
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
    
    if($_POST["nome"])
        $nome = "%".strtoupper ($_POST["nome"])."%";
    else 
        $nome = "%";
    
       $sql = "SELECT * FROM tbFornecedor WHERE nome like '$nome' "; // seleciona os Fornecedores  
              
       $result = pg_query($sql);
   
?>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <LINK REL=StyleSheet HREF="main.css" TYPE="text/css" MEDIA=screen>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>   
        <link rel="stylesheet" href="main.css" />
    </head>
    <body>
        
        <h2 >CONSULTA DE FORNECEDORES</h2> <br>
        <form name="cadastroAmigo" action="indexUser.php?link=11" method="POST">
        
        <table border="0" style="border: 0px solid #ccc;" align="center">
            <thead>
            <th colspan="3" align="center">
                Filtro
            </th>
            </thead>
            <tbody>
                <tr align="center">
                    <td>Pesquisa: </td>
                    <td><input type="text" size="40" name="nome" value="" /></td>
                    <td><input  type="submit"  value="Buscar" /></td>
                </tr>
                
            </tbody>
        </table>
    </form>
        <?
       
              
             
              
           ?>
        
        <table width="100%" border="0"  align="center" style="border: 1px solid #ccc;"  >
            <thead>
                <tr>
            <th colspan="2">Lista de Fornecedores</th>
                </tr>
                <tr>
                <th >Nome</th>
                </tr>
                
            </thead>     
            <tbody>
                <?
                
                if(pg_num_rows($result) == 0)
                { ?>
                    <tr>
                        <td align="center" style="border: 1px solid #ccc;" colspan="2"><?echo "NÃO HÁ FORNECEDORES" ?> </td>
                        
                    </tr>
                <?}
                
                
                while($colum = pg_fetch_array($result)){?>
                    <tr>
                        <td align="center" style="border: 1px solid #ccc;"><?echo $colum["nome"]; ?> </td>
                    </tr>
                    <?}?>
                </tbody>
            </table>

        <? $conexao->desconectBD();?>
    </body>
    
</html>
